package cn.zl.springbootkafka.controller;

import cn.zl.springbootkafka.product.KafkaProducter;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Description:Kafka控制器
 * @Author: zllwsy
 * @Date: 2020/10/28 16:51
 */
@Controller
@RequestMapping("/kafka")
@Slf4j
public class KafkaController {
    @Autowired
    private KafkaProducter kafkaProducter;

    @GetMapping("/send")
    @ResponseBody
    @Transactional(rollbackFor = Exception.class)
    public void  sendMsg(){
        kafkaProducter.send("Diamond U are my apple of my eyes");
    }
}
